<?php


namespace app\general\controller;


use app\common\Recharge;
use app\general\model\SqJinzhu;
use think\Controller;

/**
 * Class QueryPhone
 * @package app\general\controller
 * 话费查询接口
 */
class QueryPhone extends Controller
{
    /**
     * 话费查询,并同步phone_money
     */
    public function bingPhone(){
        $where=array(
            "create_time"=>array("gt",1568563200)
        );
        $list=(new SqJinzhu())->field("id,mobile")->where($where)->select();
        foreach ($list as $l){
            $result=(new Recharge())->myPhoneMoney($l['mobile']);
            if(!empty($result)){
                (new SqJinzhu())->save(['phone_money'=>$result['money']],['id'=>$l['id']]);
            }
        }
        echo "完成";

    }
    //记录定时器调用时间
    public function recordTimers($type)
    {
        $data = [
            'type' => $type,
            'create_time' => time(),
            'status' => 0
        ];
        return db('sq_record_timer')->insertGetId($data);
    }

    public function updateTimerType($id,$remark='')
    {
        db('sq_record_timer')->where('id', $id)->update(['status'=>1, 'remark'=>$remark]);
    }
}